package com.bdqn.Service;


public class TextPaper implements Paper {

    private int charPerLine = 16;//每行字符数
    private int linePerPage = 5;//每页行数
    private String content = "";//纸张中内容
    private int posX = 0;  //当前横向位置，从 0 到 charPerLine-1
    private int posY = 0;//当前行数，从 0 到 linePerPage-1
    private int posP = 1;    //当前页数


    @Override
    public void putInChar(char c) {
        content +=c;
        ++posX;
        //判断是否换行
        if(posX == charPerLine){
            content +=   Paper.NEW_LIKE;
//            content += Paper.newline;
            posX =  0;
            ++posY;
        }
//4
    }

    @Override
    public String getContent() {
        String ret = this.content;
        if (!(posX == 0 && posY == 0)) {
            ret += Package.newline;
            ret += "==第" + posP + "页==";
        }
        return null;
    }
}
